# 导包
import requests
import config


# 创建接口类
class LoginAPI:
    # 初始化
    def __init__(self):
        self.session = requests.session()

    # 1、获取图片验证码
    def get_image_code(self, r):
        return self.session.get(url=config.BASE_URL + f"/common/public/verifycode1/{r}")
        # return requests.get(url=config.BASE_URL + "/common/public/verifycode1/{}".format(r))

    # 2、获取短信验证码
    def get_phone_code(self, phone_data):
        return self.session.post(url=config.BASE_URL + "/member/public/sendSms", data=phone_data)

    # 3、注册
    def reg(self, reg_data):
        return self.session.post(url=config.BASE_URL + "/member/public/reg", data=reg_data)

    # 4、登录
    def login(self, login_data):
        return self.session.post(url=config.BASE_URL + "/member/public/login", data=login_data)

    # 5、是否登录


if __name__ == '__main__':
    response = LoginAPI().login(config.LOGIN_DATA)
    print(response.status_code)
    print(response.json())
